package minimips.computer;

public class JumpCondition {

	boolean willJump;
	boolean offset;
	int programAddress;
	
	public JumpCondition(boolean willJump, boolean offset, int programAddress) {
		this.willJump = willJump;
		this.offset = offset;
		this.programAddress = programAddress;
	}
	
	public JumpCondition() {
		this(false, false, 0);
	}
	
	public boolean isEnabled() {
		return this.willJump;
	}

	public boolean willJump() {
		return !offset && willJump;
	}
	
	public boolean willBranch() {
		return offset && willJump;
	}
	
	public void enableJump(int absoluteAddress) {
		this.willJump = true;
		this.offset = false;
		this.programAddress = absoluteAddress;
	}
	
	public void enableBranch(int offset) {
		this.willJump = true;
		this.offset = true;
		this.programAddress = offset;
	}

	public void reset() {
		this.willJump = false;
		this.offset = false;
		this.programAddress = 0;
	}
	
	public int getJumpValue() {
		return this.programAddress;
	}
}
